<?php if(!defined('A')) exit;?>
<div id="destoon_comment">
	<a name="top"></a>
	<div class="stat">
	<table cellpadding="6" cellspacing="1" width="100%">
	<tr align="center">
	<td width="100">好评 <img src="<?php echo PROJECT_IMG_URL;?>star3.gif" width="36" height="12" alt="" align="absmiddle"/> </td>
	<td><div class="stat_p"><div style="width:<?php echo $stat['pc3'];?>;"></div></div></td>
	<td class="stat_c" width="100"><?php echo $stat['pc3'];?></td>
	<td class="stat_t" width="80" bgcolor="#E1F0FB"><?php echo $stat['star3'];?></td>
	</tr>
	<tr align="center">
	<td>中评 <img src="<?php echo PROJECT_IMG_URL;?>star2.gif" width="36" height="12" alt="" align="absmiddle"/></td>
	<td><div class="stat_p"><div style="width:<?php echo $stat['pc2'];?>;"></div></div></td>
	<td><?php echo $stat['pc2'];?></td>
	<td bgcolor="#F2F8FD"><?php echo $stat['star2'];?></td>
	</tr>
	<tr align="center">
	<td>差评 <img src="<?php echo PROJECT_IMG_URL;?>star1.gif" width="36" height="12" alt="" align="absmiddle"/></td>
	<td><div class="stat_p"><div style="width:<?php echo $stat['pc1'];?>;"></div></div></td>
	<td><?php echo $stat['pc1'];?></td>
	<td bgcolor="#F9FCFE"><?php echo $stat['star1'];?></td>
	</tr>
	</table>
	</div>
	<?php
	if(!empty($return)) {
		foreach($return[0] as $k=>$v){
	?>
	<div class="comment">
	<table>
	<tr>
	<td class="comment_l" valign="top">
	<div>
	
	</div>
	</td>
	<td valign="top">
		<div class="comment_title">
			<span class="comment_floor">第 <strong><?php echo $v['floor']; ?></strong> 楼</span>
			<span id="i_<?php echo $v['id'];?>"><?php echo $v['name'];?> 于 <span class="comment_time"><?php echo date('Y-m-d H:i:s',$v['timestring']);?></span> 评论道：</span>
		</div>
		<div class="comment_content" id="c_<?php echo $v['id'];?>">
        <?php
        if($v['quotation']){
			echo $v['quotation'];
		}else{
			echo $v['content'];	
		}
		?>
        </div>
        <?php 
		if($v['reply']){
		?>
		<div class="comment_reply">
        <?php
        	if($v['editor']){
		?>
        <span style="color:red;">管理员</span>
        <?php
			}else{
		?>
        <span style="color:blue;"><?php echo $v['replyer'];?></span>
        <?php
			}
		?>
		 <span style="font-size:11px;"><?php echo date('Y-m-d H:i:s',$v['replytime']);?></span> 
         回复：
         <?php echo nl2br($v['reply']);?>
		</div>
		<?php
		}
		?>
		<div class="comment_info">
			<span class="comment_vote">
			<a href="javascript:" onclick="R(<?php echo $v['id'];?>);">举报</a>&nbsp; | &nbsp;
			<a href="javascript:" onclick="V(<?php echo $v['id'];?>, 1, <?php echo $v['agree'];?>);">支持</a>(<span id="v_<?php echo $v['id']?>_1"><?php echo $v['agree'];?></span>)&nbsp; | &nbsp;
			<a href="javascript:" onclick="V(<?php echo $v['id'];?>, 0, <?php echo $v['against'];?>);">反对</a>(<span id="v_<?php echo $v['id'];?>_0"><?php echo $v['against'];?></span>)&nbsp; | &nbsp;
			<a href="javascript:" onclick="Q(<?php echo $v['id'];?>);">引用</a>(<?php echo $v['quote'];?>)
			</span>
			<img src="<?php echo PROJECT_IMG_URL;?>star<?php echo $v['star']?>.gif" width="36" height="12" alt="" align="absmiddle"/>
		</div>
	</td>
	</tr>
	</table>
	</div>
	<?php
		}
	?>
	<a name="last"></a>
	<div align="center"><?php echo $return[1];?></div>
    <?php
	}else{
	?>
    <div align="center">暂无评论！</div>
    <?php
	}
	?>
	<iframe src="" name="send" id="send" style="display:none;" scrolling="no" frameborder="0"></iframe>
	<div class="comment_form">
	<form method="post" action="<?php echo url('comment','comment_');?>" target="_self" id="my_comment_form">
	<input type="hidden" name="mid" value="<?php echo $mid;?>"/>
	<input type="hidden" name="arc_id" value="<?php echo $arc_id;?>"/>
	<input type="hidden" name="items" value="<?php echo $items;?>"/>
	<input type="hidden" name="page_id" value="<?php echo $page_id;?>"/>
	<input type="hidden" name="qid" value="0" id="qid"/>
	<table cellpadding="10" cellspacing="1" width="100%">
	<tr>
	<td id="qbox" style="display:none;" bgcolor="#F9FCFE"></td>
	</tr>
	<tr>
	<td>
	<input type="radio" name="star" value="3" id="star_3" checked/><label for="star_3"> 好评 <img src="<?php echo PROJECT_IMG_URL;?>star3.gif" width="36" height="12" alt="" align="absmiddle"/></label>
	<input type="radio" name="star" value="2" id="star_2"/><label for="star_2"> 中评 <img src="<?php echo PROJECT_IMG_URL;?>star2.gif" width="36" height="12" alt="" align="absmiddle"/></label>
	<input type="radio" name="star" value="1" id="star_1"/><label for="star_1"> 差评 <img src="<?php echo PROJECT_IMG_URL;?>star1.gif" width="36" height="12" alt="" align="absmiddle"/></label>
	</td>
	</tr>
	<tr>
	<td><textarea class="comment_area"  name="content" id="content" style="resize:none;"></textarea></td>
	</tr>
	<tr>
	<td><div class="comment_input">&nbsp;<span>*</span> 验证码：&nbsp;<input  type="text" name="captcha" id="captcha" value="" autocomplete="off" />&nbsp;<img src="" id="imgcode" align="absmiddle" title="点击更换" /></div></td>
	</tr>
	<tr>
	<td>
	&nbsp;<input type="submit" class="btn" value="提交评论" align="absmiddle"/>
	&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#666666;">(内容限5至300字)
	&nbsp;&nbsp;&nbsp;&nbsp;当前已经输入 <span style="color:red;" id="chars">0</span> 字
	</span>
	</td>
	</tr>
	</table>
	</form>
	</div>	
	<form method="post" action="<?php echo url('guestbook','add','type=5');?>" id="r_form" target="_blank">
	<input type="hidden" name="content" id="r_content" value=""/>
	</form>
</div>
<script>
$(document).ready(function(){
		var imgcode=$('#imgcode');
		imgcode.css('cursor','pointer').hide();
		$('#captcha').focus(function(){
			if(imgcode.attr('src')==''){
				imgcode.attr('src','/code.php?'+Math.random()).fadeIn();
			}
		});
		imgcode.click(function(){
			$(this).attr('src','/code.php?'+Math.random());
		});
});
$('#content').keyup(function(){
	$('#chars').html($('#content').val().length);
});
$('#my_comment_form').submit(function(){
	if($('#content').val().length < 5) {
		confirm('内容最少需要5字');
		$('#content').focus();
		return false;
	}
	if($('#content').val().length > 300) {
		confirm('内容最多300字');
		$('#content').focus();
		return false;
	}
	if($('#captcha').val().length<4) {
		confirm('请填写验证码');
		H();
		$('#captcha').focus();
		return false;
	}
	return true;
});
function R(id) {
	$('#r_content').val('评论举报，评论ID:'+id+'\n评论内容:\n'+$('#c_'+id).html()+'\n--------------------------\n举报理由:\n');
	$('#r_form').submit();
}
var v_id = 0;
var v_op = 1;
var v_nm = 0;
function V(id, op, nm) {
	v_id = id;
	v_op = op;
	v_nm = nm;
	if(get_cookie('comment_vote_<?php echo $mid;?>_<?php echo $arc_id;?>_'+id)) {
		confirm('您已经对此评论表过态了');
		return;
	}
	$.post('<?php echo url('comment','ajax_vote');?>',{'mid':'<?php echo $mid;?>','arc_id':'<?php echo $arc_id;?>','cid':id,'op':op},function(data){
			var code=parseInt(data.code);
			if(code<0){
				alert(code.msg);	
				return;
			}else{
				if(v_op==1){
					$('#v_'+v_id+'_1').html(++v_nm);
				}else{
					$('#v_'+v_id+'_0').html(++v_nm);
				}
			}
	},'json');
}
function Q(qid){
	  $('#qid').val(qid);
	  $('#qbox').show();
	  $('#qbox').html('&nbsp;<strong>引用:</strong><div class="comment_title">'+$('#i_'+qid).html()+'</div><div class="comment_content">'+$('#c_'+qid).html()+'</div>');
	  H();
	  $('#content').focus();
}
try{$('#comment_count',parent.document).html('<?php echo $items;?>');}catch(e){}
function H() {
	try{$('#destoon_comment',parent.document).get(0).style.height = $('#destoon_comment').get(0).scrollHeight+'px';}
	catch(e){}
}
H();

</script>